using System;
using System.Collections;
using Curriculum.Modelo.Clases;
using Curriculum.Utiles;

namespace Curriculum.Services
{
	/// <summary>
	/// Summary description for LookupTypeService.
	/// </summary>
	public class LookupTypeService : ServiceBase
	{
		public LookupTypeService()
		{
		}


		protected override Type GetMyObjectType()
		{
			return typeof(LookupType);
		}

		public void GuardarNuevoLookUp(string descripcion, string descLookupType)
		{
			string idLookup = IdGenerator.GetNextId(typeof(Lookup), dataManager.Container);
			LookupType lookupType = dataManager.GetLookupTypeByCodigo(descLookupType);
			Lookup lookup = new Lookup(descripcion, idLookup, lookupType);

			dataManager.SetObjejct(lookup);
		}

		public IList GetLookupsPorCodigo(string codigo)
		{
			return dataManager.GetLookUpByDescType(codigo);			
		}

		/// <summary>
		/// Crea un LookupType
		/// </summary>
		/// <param name="lookupType"></param>
		/// <returns>retorna el id con el que se dio de alta el lookupType</returns>
		public object CrearLookupType(LookupType lookupType)
		{
			return base.Crear(lookupType);
		}

		/// <summary>
		/// Crea un Lookup
		/// </summary>
		/// <param name="lookup"></param>
		/// <returns>retorna el id con el que se dio de alta el lookup</returns>
		public object CrearLookup(Lookup lookup)
		{
			return base.Crear(lookup);
		}
		/// <summary>
		/// Modifica un Lookup
		/// </summary>
		/// <param name="lookup"></param>
		/// <returns>retorna el id del lookup</returns>
		public object ModificarLookup(Lookup lookup)
		{
			return base.Modificar(lookup);
		}
		/// <summary>
		/// Elimina un Lookup
		/// </summary>
		/// <param name="lookupId">id del lookup que se quiere eliminar</param>
		/// <returns></returns>
		public void EliminarLookup(object lookupId)
		{
			base.Eliminar(typeof(Lookup), lookupId);
		}

		public LookupType ObtenerLookupType(object codigo)
		{
			return dataManager.GetLookupTypeByCodigo(codigo.ToString());
		}

		public Lookup ObtenerLookup(object lookupId)
		{
			return base.ObtenerObjetoPorId(typeof(Lookup), lookupId.ToString()) as Lookup;
		}


		#region - Deprecated -

		public IList GetAllInstituciones()
		{
			return dataManager.GetLookUpByDescType("INSTIT");
		}
		public IList GetAllDepartamentos()
		{
			return dataManager.GetLookUpByDescType("DEPART");
		}

		public IList GetLookUpByDescType(string desc)
		{				
			return dataManager.GetLookUpByDescType(desc);
		}
		public Lookup GetLookUpByDesc(string desc, string descType)
		{				
			return dataManager.GetLookUpByDesc(desc, descType);
		}
		#endregion - Deprecated -
	}
}
